<%@page import="com.oceansoft.core.common.constant.Constant"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>厅干部平时考核管理系统</title>
		<%
		session.setAttribute(Constant.LOGIN_USER, null);
		//session.setMaxInactiveInterval(0);
		
		String u= request.getHeader("host");
		if(u.indexOf(":")>-1)
		{
		 u=u.substring(0,u.indexOf(":"));
		}
		String ctx = request.getContextPath();
		String url = request.getRequestURI();
		String code = request.getRemoteUser();
	    %>
		<link rel="stylesheet" type="text/css" href="<c:url value='/resource/jxkh/css/main.css'/>"/>
		<!--日期时间控件结束-->
		<script type="text/javascript" src="<c:url value='/resource/jxkh/js/jquery-1.11.0.js'/>"></script>
	<title>登录</title>
		<style>
			.ghpf{width: 140px;height: 45px;float: left;color: #fff;font-size: 20px;text-align: center;background: #3175c0;border: 0;cursor: pointer;margin-top: 20px;margin-left:20px;}
			.ghpf:hover{background: #3f80c7;}
		</style>
		<script type="text/javascript">
		var dispsw = "";
			var debounce = function (func, threshold, execAsap) {  
			    var timeout;  
			    return function debounced () {  
			        var obj = this, args = arguments;  
			        function delayed () {  
			            if (!execAsap)  
			            func.apply(obj, args);  
			            timeout = null;  
			        };  
			        if (timeout)  
			            clearTimeout(timeout);  
			        else if (execAsap)  
			            func.apply(obj, args);  
			        timeout = setTimeout(delayed, threshold || 100);  
			    };  
			};
			
			function isBlank(targetCmpId,msgCmpId,msg){
				if ("" == $("#"+targetCmpId).val().replace(/(^\s*)|(\s*$)/g, "")) {
					//$("#btn_login").css("top","340px");
					//$("#keylogin").css("top","340px");
					$("#"+msgCmpId).text(msg);
					return false;
				}else{
					$("#"+msgCmpId).text("");
					return true;
				}
			}
			
			function trimStr(targetCmpId){
				return $("#"+targetCmpId).val().replace(/(^\s*)|(\s*$)/g, ""); 
			}
		
			document.onkeydown = function() {
				if (13 == event.keyCode) {
					if(isBlank("username","pwdErr","请输入用户名！") && isBlank("password","userErr","请输入密码！")){
						$.post("<c:url value='/profile/auth.json'/>",{policeNum:trimStr("username"),password:trimStr("password")},function(data){
							//alert(data.msg.title)
							
							if(1 == data.msg.status){
								//$("#btn_login").css("top","340px");
								//$("#keylogin").css("top","340px");
								window.location.replace("<c:url value='/profile/admin.html'/>");
							}else{
								alert(data.msg.body);
								//$("#btn_login").css("top","340px");
								//$("#keylogin").css("top","340px");
								//$("#pwdErr").text(data.msg.body);
								dispsw = data.msg.extentData ;
							}
						});
					}
				}
			};
			$(function(){
			 if("${data}"!=""){
			 $("#pwdErr").text("${data}");
			 };
			 
			 $("#pwdErr").css({"left":($(window).width()-240)/2-30,"top":($(window).height()-150)/2-30});
			 
			});
			$(function(){
				$(".ghpf").click(function () {
					var x = $(".logon").css("background-image");
					var s = x.replace('url(','').replace(')','');
					var index = s.lastIndexOf("\/");
					s  = s .substring(index + 1, s.length);
					s= s.replace('"',"");
					s=s.split(".")[0];
					s=s.substring(s.length-1);
					if(s==6){
						s=0;
					}else{
						s= parseInt(s)+1;
					}
					s="url(resource/jxkh/images/backgroudpic/pic"+s+".jpg)";
					$(".logon").css("background-image",s);
				});
				/*	$(".logon").css("")
				 });
				 function changeBackgroud(){

				 }*/
				$("#btn_login").click(function(){
					if(isBlank("username","pwdErr","请输入用户名！") && isBlank("password","pwdErr","请输入密码！")){
						$.post("<c:url value='/profile/auth.json'/>",{policeNum:trimStr("username"),password:trimStr("password")},function(data){
							//alert(data.msg.title)
							if(1 == data.msg.status){
							//	$("#btn_login").css("top","340px");
							//	$("#keylogin").css("top","340px");
							 	window.location.replace("<c:url value='/profile/admin.html'/>");
							}else{
								//$("#btn_login").css("top","340px");
								//$("#keylogin").css("top","340px");
								alert(data.msg.body);
								//$("#pwdErr").text(data.msg.body);
								dispsw = data.msg.extentData ;
							}
						});
					}
					return;
				});
			});
			
			
			function showPWD()
			{
				$("#pwdErr").text(dispsw);
				$("#password").val(dispsw);
			}
		</script>
</head>

	<body>
	<div class="logon">
		<div class="ghpf_div" style="position: fixed">
			<button type="button" class="ghpf">更换皮肤</button>
		</div>
		<div class="logon_main">
			<div class="logon_main_top">
				<img src="<c:url value='/resource/jxkh/images/logo_big.png'/>" />
			</div>
			<div class="logon_main_bottom">
				<div class="title">
					<img src="<c:url value='/resource/jxkh/images/logon_text.png'/>" />
				</div>
				<div class="content">
					<div class="row_inpt">
						<div class="row_inpt_lf icon1"></div>
						<div class="row_inpt_rt">
							<input type="text" placeholder="用户名"  id="username" name="policeNum"  class="inpt" />
						</div>
					</div>
					<div class="row_inpt">
						<div class="row_inpt_lf icon2"></div>
						<div class="row_inpt_rt">
							<input type="password" placeholder="密码" id="password" name="password"  class="inpt" />
						</div>
					</div>
					<div class="row_btn">
						<div class="row_btn_lf" style="display: none">* 您输入的密码不正确，请重新输入</div>
						<button type="button" class="row_btn_rt" style="margin-right: 40px;">KEY登录</button>
						<button type="button" class="row_btn_rt" id="btn_login"  style="margin-right: 40px;" >登录</button>
					</div>
				</div>
			</div>
		</div>
	</div>
	</body>
</html>